package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.*;
import com.ssy.lingxi.order.model.vo.basic.response.*;
import com.ssy.lingxi.order.service.web.IMemberSalesAchievementCountService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @author 郑小翠
 * @version 2.02.18
 * @menu 订单能力 - 业务员业绩统计
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/order/member/sales/achievement/count")
public class MemberSalesAchievementCountController {

    @Resource
    IMemberSalesAchievementCountService memberSalesService;

    /**
     * 业务员业绩统计
     */
    @RequestMapping(value = "/memberSales/information", method = RequestMethod.POST)
    public Wrapper<PageData<MemberSalesAchievementCountVO>> findAllMemberSales(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderMemberSalesCountVO pageVO) {
        return memberSalesService.findAllMemberSalesAchievement(headers, pageVO);
    }

    /**
     * 业务员业绩详情-会员统计
     */
    @RequestMapping(value = "/member/information", method = RequestMethod.POST)
    public Wrapper<PageData<MemberSalesMemberQueryVO>> memberInformation(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberSalesMemberCountVO pageVO) {
        return memberSalesService.findByUserId(headers, pageVO);
    }

    /**
     * 业务员业绩详情-商品统计
     */
    @RequestMapping(value = "/commodity/information", method = RequestMethod.POST)
    public Wrapper<PageData<MemberSalesCountCommodityQueryVO>> commodityInformation(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberSalesCountCommodityVO pageVO) {
        return memberSalesService.commodityInformation(headers, pageVO);
    }

    /**
     * 业务员订单明细
     */
    @RequestMapping(value = "/order/details", method = RequestMethod.POST)
    public Wrapper<PageData<MemberSalesCountOrderDetailsQueryVO>> orderDetails(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberSalesCountOrderDetailsVO pageVO) {
        return memberSalesService.orderDetails(headers, pageVO);
    }

    /**
     * 导出业务员业绩统计
     */
    @RequestMapping(value = "/export/memberSales/information", method = RequestMethod.GET)
    public void exportFindAllMemberSales(HttpServletResponse response, @Valid MemberSalesCountExportVO pageVO, String token, String referer) {
        memberSalesService.exportFindAllMemberSales(response, pageVO, token, referer);
    }

    /**
     * 导出会员统计
     */
    @RequestMapping(value = "/export/member/information", method = RequestMethod.GET)
    public void exportMemberInformation(HttpServletResponse response, @Valid MemberSalesMemberCountExportVO pageVO, String token) {
        memberSalesService.exportFindByUserId(response, pageVO, token);
    }

    /**
     * 导出商品统计
     */
    @RequestMapping(value = "/export/commodity/information", method = RequestMethod.GET)
    public void exportCommodityInformation(HttpServletResponse response, @Valid MemberSalesCountCommodityVO pageVO, String token) {
        memberSalesService.exportCommodityInformation(response, pageVO, token);
    }

    /**
     * 导出业务员订单明细
     */
    @RequestMapping(value = "/export/order/details", method = RequestMethod.GET)
    public void exportOrderDetails(HttpServletResponse response, @Valid MemberSalesCountOrderDetailsVO pageVO, String token, String referer) {
        memberSalesService.exportOrderDetails(response, pageVO, token, referer);
    }
}
